package net.zoneland.zrdp.biz.service.impl;

import java.util.List;
import net.zoneland.zrdp.common.utils.DateUtil;
import org.springframework.stereotype.Service;
import net.zoneland.zrdp.biz.mapper.FlowMainInfoMapper;
import net.zoneland.zrdp.biz.domain.FlowMainInfo;
import net.zoneland.zrdp.biz.service.IFlowMainInfoService;

import javax.annotation.Resource;

/**
 * 流程工单记录Service业务层处理
 *
 * @author zonevue
 */
@Service
public class FlowMainInfoServiceImpl implements IFlowMainInfoService {

    @Resource
    private FlowMainInfoMapper flowMainInfoMapper;

    /**
     * 查询流程工单记录
     *
     * @param id 流程工单记录主键
     * @return 流程工单记录
     */
    @Override
    public FlowMainInfo selectFlowMainInfoById(final Long id) {
        return flowMainInfoMapper.selectFlowMainInfoById(id);
    }

    /**
     * 查询流程工单记录列表
     *
     * @param flowMainInfo 流程工单记录
     * @return 流程工单记录
     */
    @Override
    public List<FlowMainInfo> selectFlowMainInfoList(final FlowMainInfo flowMainInfo) {
        return flowMainInfoMapper.selectFlowMainInfoList(flowMainInfo);
    }

    /**
     * 综合查询
     *
     * @param flowMainInfo 流程工单记录
     * @return 流程工单记录
     */
    @Override
    public List<FlowMainInfo> integratedQuery(final FlowMainInfo flowMainInfo) {
        return flowMainInfoMapper.integratedQuery(flowMainInfo);
    }

    /**
     * 新增流程工单记录
     *
     * @param flowMainInfo 流程工单记录
     * @return 结果
     */
    @Override
    public int insertFlowMainInfo(final FlowMainInfo flowMainInfo) {
        flowMainInfo.setCreateTime(DateUtil.getNowLocalDateTime());
        return flowMainInfoMapper.insertFlowMainInfo(flowMainInfo);
    }

    /**
     * 修改流程工单记录
     *
     * @param flowMainInfo 流程工单记录
     * @return 结果
     */
    @Override
    public int updateFlowMainInfo(final FlowMainInfo flowMainInfo) {
        flowMainInfo.setUpdateTime(DateUtil.getNowLocalDateTime());
        return flowMainInfoMapper.updateFlowMainInfo(flowMainInfo);
    }

    /**
     * 批量删除流程工单记录
     *
     * @param ids 需要删除的流程工单记录主键
     * @return 结果
     */
    @Override
    public int deleteFlowMainInfoByIds(final Long[] ids) {
        return flowMainInfoMapper.deleteFlowMainInfoByIds(ids);
    }

    /**
     * 删除流程工单记录信息
     *
     * @param id 流程工单记录主键
     * @return 结果
     */
    @Override
    public int deleteFlowMainInfoById(final Long id) {
        return flowMainInfoMapper.deleteFlowMainInfoById(id);
    }

    /**
     * 根据workId或者piid查询工单信息.
     * @param workId 工单号.
     * @param piid 流程编码.
     * @return FlowMainInfo 工单信息
     **/
    @Override
    public FlowMainInfo getInfoByWorkIdOrPiid(final String workId, final String piid) {
        return flowMainInfoMapper.selectFlowMainInfoByWorkIdOrPiid(workId, piid);
    }

    /**
     * 根据piid查询工单.
     * @param piid 流程编码.
     * @return FlowMainInfo 工单信息
     **/
    @Override
    public FlowMainInfo getInfoByPiid(final String piid) {
        return flowMainInfoMapper.selectFlowMainInfoByPiid(piid);
    }
}
